<?php

namespace app\index\model;

use think\Model;

class Goods extends Model
{

    public static function GoodsListInfo($where)
    {
        $list = Goods::field('goods_id,goods_name,price,default_image')->where($where)->where('recommended', '=', '1')->limit(6)->select();
        $recom = Goods::field('goods_id,goods_name,price,default_image')->where($where)->where('recom', '=', '1')->limit(6)->select();
        return [$list, $recom];
    }

    public static function getGoodsNametextAttr($v, $d){
      if (mb_strlen($d['goods_name']) > 8) {
            return mb_substr($d['goods_name'], 0, 8, 'utf-8') . '...';
       } else {
          return $d['goods_name'];
     }
    }

     public static function   cateGoodsInfo($get,$where){
        $list=Goods::field('goods_id,goods_name,price,default_image')->where($where)->where('cate_id','=',$get['id'])->select()->toArray();
            return $list;
     }
      public static function   goodsInfoList($get){
        $list=Goods::field('goods_id,goods_name,price,images,vip,description')->where('goods_id','=',$get['id'])->find()->toArray();
        return $list;
      }


}